package co.edu.unal.geditor.model;

import java.awt.Color;
import java.awt.Font;
import java.awt.Point;

import co.edu.unal.geditor.view.ElementView;
import co.edu.unal.geditor.view.TextGraphView;

public class TextElement extends ClosedGraphElement
{
	private static final long serialVersionUID = 1L;
	
	protected TextElement( Point pUL, Point pBD )
	{
		super( pUL, pBD );
		
		setText( "" );
	}
	public static Font getDefault_font() {
		return default_font;
	}

	public static void setDefault_font(Font default_font) {
		TextElement.default_font = default_font;
	}
	public TextElement( Point pUL, Point pBD, String text)
	{
		super( pUL, pBD);
		setText( text );
		
		setFont(new Font(default_font.getFontName(),default_font.getStyle(),m_boundBox.getHeight()));
	}
	
	protected TextElement( Point pUL, Point pBD, Color color, String text )
	{
		super( pUL, pBD, color );
		setText( text );
		setFont(new Font(default_font.getFontName(),default_font.getStyle(),m_boundBox.getHeight()));
	}
	public Font getFont() {
		return m_font;
	}

	public void setFont(Font font) {
		
		this.m_font=new Font(font.getFontName(), font.getStyle(), font.getSize());

	}
	
	public String getText()
	{
		return m_text;
	}
	
	public void setText( String text )
	{
		assert text != null;
		
		m_text = text;
	}

	@Override
	protected ElementView createView()
	{
		// start with graphics view by default
		
		return new TextGraphView( this );
	}
	
	// the text this element renders
	private String m_text;
	private Font m_font;
	private static Font default_font = new Font(Font.SERIF,Font.PLAIN,50);

	


}
